package com.sc.nft.admin.controller;
import com.sc.nft.annotation.SysMemberLogin;
import com.sc.nft.feign.WxMiniUserPointsClient;
import com.sc.nft.req.points.PointsPageReq;
import com.sc.nft.req.points.PointsReq;
import com.sc.nft.req.points.PointsUpdateReq;
import com.sc.nft.req.points.webPointsGetRecordReq;
import com.sc.nft.sup.PageResult;
import com.sc.nft.sup.Result;
import com.sc.nft.vo.points.PointsPageVO;
import com.sc.nft.vo.points.PointsRecordsPageVO;
import com.sc.nft.vo.points.PointsStatisticsVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/admin/wxMiniMall/points")
@Api(tags = "小程序用户积分")
public class WxMiniPointsController{

    private final WxMiniUserPointsClient wxMiniUserPointsClient;


//    /**
//     * 加积分
//     * @return
//     */
//    @PostMapping(value = "/addPoints", produces = MediaType.APPLICATION_JSON_VALUE)
//    @ApiOperation(value = "加积分")
//    public Result<Boolean> addPoints(@RequestBody PointsReq req) {
//        return wxMiniUserPointsClient.addPoints(req);
//    }
//
//
//    /**
//     * 减积分
//     * @return
//     */
//    @PostMapping(value = "/subPoints", produces = MediaType.APPLICATION_JSON_VALUE)
//    @ApiOperation(value = "减积分")
//    public Result<Boolean> subPoints(@RequestBody PointsReq req) {
//        return wxMiniUserPointsClient.subPoints(req);
//    }

    /**
     * 个人积分详情
     * @return
     */
    @PostMapping(value = "/statistics", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "积分统计")
    @SysMemberLogin
    public Result<PointsStatisticsVO> statistics() {
        return wxMiniUserPointsClient.statistics();
    }


    /**
     * 个人积分详情
     * @return
     */
    @PostMapping(value = "/adminPage", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "所有用户积分列表")
    @SysMemberLogin
    public PageResult<PointsPageVO> adminPage(@RequestBody PointsPageReq request) {
        return wxMiniUserPointsClient.adminPage(request);
    }

    /**
     * 个人积分后台修改
     * @return
     */
    @PostMapping(value = "/update", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "修改用户积分")
    @SysMemberLogin
    public Result update(@RequestBody PointsUpdateReq request) {
        return wxMiniUserPointsClient.update(request);
    }

    /**
     * 积分变动记录
     * @return
     */
    @PostMapping(value = "/pointsRecords", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "积分变动记录")
    @SysMemberLogin
    public PageResult<PointsRecordsPageVO> pointsRecords(@RequestBody webPointsGetRecordReq request) {
        return wxMiniUserPointsClient.pointsRecords(request);
    }

}